/*
 * @Author: wangjing wangjin122@qq.com
 * @Date: 2024-02-22 15:27:16
 * @LastEditors: wangjing wangjin122@qq.com
 * @LastEditTime: 2024-02-22 16:33:21
 * @FilePath: \枚举类型\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

// 数字枚举
enum Color {
  red,
  green = 5,
  blue
}
console.log(Color)

/**
 * const枚举
 *    会把枚举编译成常量
 *    而不用const则编译成枚举对象
 */
const enum Types {
  suc,
  fail
}
const code: number = 0
if(code === Types.suc) {}

// 反向映射
enum ReTypes {
  fir // 数字才能进行反向映射
  // fir = '1' // 字符串不行，会报错
}
const res = ReTypes.fir
const key = ReTypes[res]
console.log('value:', res)
console.log('key:', key)
